import pygame
import spyral
import math

import Dic


class Power(spyral.sprite.Sprite):
    def __init__(self):
        spyral.sprite.Sprite.__init__(self)
        self.image = spyral.util.new_surface(610, 60)
        self.image.fill(Dic.colors['white'])
        self.image.fill(Dic.colors['black'], pygame.Rect(5,5,600,50))
        self.layer = 3;
        self.pos = (Dic.geom['width'] / 2 - self.image.get_width() / 2,
                    Dic.geom['height'] / 2 - self.image.get_height() / 2)
        self.speed = 0;
        self.percent = float(0);
        self.up = True;
        
    def update(self, tick):
        if (self.up == True):
            self.percent += self.speed;
            self.speed += .01;
            if (self.percent >= 1):
                self.percent = 1;
                self.up = False;
        else:
            self.percent -=self.speed;
            self.speed -= .01;
            if (self.percent <= 0):
                self.percent = 0;
                self.up = True;
                self.speed = 0;
        self.image.fill(Dic.colors['black'], pygame.Rect(5,5,600,50))
        self.image.fill(Dic.colors['green'], pygame.Rect(5,5,600 * self.percent,50))
    
    def getPercent(self):
        return self.percent;
    
    
        
        
        